//
//  StatisticalAnalysisOneCell.m
//  EMMApp
//
//  Created by Mac on 17/1/10.
//  Copyright © 2017年 YiXun. All rights reserved.
//

#import "StatisticalAnalysisOneCell.h"
#import "StatisticalCVCell.h"

@interface StatisticalAnalysisOneCell ()<UICollectionViewDataSource,UICollectionViewDelegate,UICollectionViewDelegateFlowLayout>

@property (nonatomic, strong) NSMutableArray *dataNameArr;
@property (nonatomic, strong) NSMutableArray *dataImageVArr;

@end

@implementation StatisticalAnalysisOneCell

- (void)awakeFromNib {
    [super awakeFromNib];
    _touyingView.layer.shadowColor = [UIColor colorFromHexCode:@"#5A5A5A"].CGColor;//阴影颜色
    _touyingView.layer.shadowOffset = CGSizeMake(0, 0);//偏移距离
    _touyingView.layer.shadowOpacity = 0.5;//不透明度
    _touyingView.layer.shadowRadius = 3.0;//半径
    
    _dataNameArr = [NSMutableArray arrayWithObjects:
                    @"客户分析",@"已签约未回款",@"工作量统计",
                    @"销售指标",@"成交房产",@"存量时间",
                    @"算价分析",@"成交房源",@"存量房源", nil];
    _dataImageVArr = [NSMutableArray arrayWithObjects:
                      @"fx_kh",@"fx_ico6",@"fx_ico7",
                      @"fx_gzl",@"fenxi_06",@"fenxi_07",
                      @"fenxi_08",@"fenxi_09",@"fenxi_10", nil];
    [self creatCollectionView];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark - UICollectionView初始化
- (void)creatCollectionView {
    UICollectionViewFlowLayout *layuet = [[UICollectionViewFlowLayout alloc] init];
    //垂直行间距
    layuet.minimumLineSpacing = 0;
    //水平间隔
    layuet.minimumInteritemSpacing = 0;
    [layuet setScrollDirection:UICollectionViewScrollDirectionVertical];
    [self.homeCollectionView registerNib:[UINib nibWithNibName:@"StatisticalCVCell" bundle:nil] forCellWithReuseIdentifier:@"StatisticalCVCell"];
    self.homeCollectionView.delegate = self;
    self.homeCollectionView.dataSource = self;
    self.homeCollectionView.backgroundColor = [UIColor whiteColor];
    self.homeCollectionView.scrollEnabled = NO;
    
}

#pragma mark - UICollectionViewDataSource / UICollectionViewDelegate /UICollectionViewDelegateFlowLayout 代理
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    
    return _dataNameArr.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *cellId = @"StatisticalCVCell";
    StatisticalCVCell *homeCell = [collectionView dequeueReusableCellWithReuseIdentifier:cellId forIndexPath:indexPath];
    homeCell.staisNameLabel.text = [_dataNameArr objectAtIndex:indexPath.row];
    homeCell.staisImageV.image = [UIImage imageNamed:[_dataImageVArr objectAtIndex:indexPath.row]];
    return homeCell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake((EMM_WIDTH-20)/3, 70);
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 0, 0, 0);
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    NSLog(@"%ld",indexPath.row);
    if (self.statisicalDelegate!=nil &&[self.statisicalDelegate respondsToSelector:@selector(initwithcollecttionIdex:)]) {
        [self.statisicalDelegate initwithcollecttionIdex:indexPath.row];
    }
}

@end
